package cn.itcast.bos.service.base.impl;

import cn.itcast.bos.dao.base.AreaRespository;
import cn.itcast.bos.domain.base.Area;
import cn.itcast.bos.domain.base.Courier;
import cn.itcast.bos.service.base.AreaService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



import java.util.List;

@Transactional
@Service
public class AreaServiceImpl implements AreaService {

    @Autowired
    private AreaRespository areaRespository;

    @Override
    public void save(List<Area> areas) {
        areaRespository.save(areas);
    }

	@Override
	public Page<Area> findAll(Specification<Area> spec, Pageable pageable) {
		return areaRespository.findAll(spec, pageable);
	}

	@Override
	public List<Area> findAll() {
		return areaRespository.findAll();
	}

	@Override
	public void save(Area model) {

		areaRespository.save(model);
	}

	@Override
	public List<String> findProvince() {
		return areaRespository.findProvince();
	}

	@Override
	public List<Area> findArea(String province, String city, String district) {
		return areaRespository.findByProvinceAndCityAndDistrict(province,city,district);
	}

	@Override
	public List<String> findCity(String province) {
		return areaRespository.findCity(province);
	}

	@Override
	public List<String> findDistrict(String province, String city) {
		return areaRespository.findDistrict(province,city);
	}
}
